<template>
<view class="com-wrap">
  <view class="user-info-wrap">
    <view class="avatar-wrap">
      <image class="avatar" :src="user.avatar"/>
    </view>
    <view class="info-wrap">
      <view>Hello,{{ user.nickname }}</view>
      <view>欢迎使用蓝豹动态码</view>
    </view>
  </view>
  <view class="fast-make-wrap">
    <view>一键生成，万物皆可“码”</view>
    <view>智能转换｜多场景扫码即用</view>
    <view @click="toPage('/yixu/pages/dynamic_code/qrcode_create')">
      <view class="btn">立即制作</view>
    </view>

  </view>
  <view class="card-wrap">
    <view>
      <view>生成二维码</view>
      <view>一键生成，万物皆可“码”</view>
    </view>
    <view @click="toPage('/yixu/pages/dynamic_code/qrcode_create')">
      <view class="btn">去生成</view>
    </view>
  </view>
  <view class="card-wrap">
    <view>
      <view>创建产品</view>
      <view>创建金融产品</view>
    </view>
    <view @click="toPage('/yixu/pages/dynamic_code/product_create')">
      <view class="btn">去生成</view>
    </view>
  </view>

</view>
</template>


<script>
import {getUser} from "../../../../api/user.js";
import {createQrCodeNum} from "../../../../api/app.js";

export default {
  name: "index",
  emits:['check','to'],
  data() {
    return {
      user: {}
    };
  },
  created() {
    this.init();
  },
  methods: {
    async init() {
      const res = await getUser();
      this.user = res.data;
    },

    async toPage(url) {
      const res = await createQrCodeNum();
      if(res.code == 1){
        if(res.data.paid_status == 1){
          this.$emit('to',url);
        }else{
          this.$emit('check');
        }
      }

    }
  }
}
</script>


<style scoped lang="scss">

.com-wrap {
  padding: 40rpx 30rpx;
}

.user-info-wrap {
  padding-top: 30rpx;
  display: flex;
  align-items: center;
  gap: 20rpx;

  .avatar-wrap {
    border-radius: 20rpx;
    border: 4rpx solid #ffffff;
    width: 80rpx;
    height: 80rpx;

    .avatar {
      width: 100%;
      height: 100%;
    }
  }

  .info-wrap {
    view:first-child {
      font-weight: 600;
      margin-bottom: 6rpx;
      color: #11141F;
    }

    view:last-child {
      color: #4F5567;
      font-size: 24rpx;
    }
  }

}

.btn {
  background: #208DF7;
  color: white;
  border-radius: 5rpx;
  padding: 10rpx 30rpx;
  display: inline-block;
  font-size: 24rpx;
}

.fast-make-wrap {
  margin-top: 40rpx;
  height: 300rpx;
  background-size: 100%;
  background-repeat: no-repeat;
  padding: 40rpx 30rpx 60rpx;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  background-image: url("https://theme.lanbaozixun.com/lbzx/dynamic_code/index_1.png");

  & > view:nth-child(1) {
    color: #002561;
    font-weight: 500;
    font-size: 40rpx;
    letter-spacing: 4px;
  }

  & > view:nth-child(2) {
    color: #002561;
    font-size: 24rpx;
    margin-bottom: 20rpx;
  }
}

.card-wrap {
  background: linear-gradient(180deg, #FAFDFF 0%, #EDF0FF 100%);
  height: 200rpx;
  margin-top: 30rpx;
  padding: 30rpx;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 40rpx;
  font-weight: 500;
  color: #002561;
  border-radius: 20rpx;
  border: 1px solid #dbe2ff;

  & > view > view:last-child {
    font-size: 24rpx;
    margin-top: 20rpx;
  }

}
</style>
